package com;

import java.util.Iterator;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.ProjectionList;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;

public class main
{
	
	public static List<process> viewRecord(String s[]){	
		
		
		
		SessionFactory sf=new Configuration().configure().buildSessionFactory();
		Session session=sf.openSession();
		
		Criteria c1=session.createCriteria(process.class);
		//ProjectionList projectionList=Projections.projectionList();
		//projectionList.add(Projections.alias(Projections.property("addid"),"addid"));
		//c.setProjection(projectionList);
		//List<Adress> list=c.setResultTransformer(new AliasToBeanResultTransformer(Adress.class)).list();
		//System.out.println("Adress id: "+ list.get(0).getAddid());		
		//Adress addid=list.get(0);
		// c1.add(Restrictions.and(Restrictions.eq("id", new Integer(0)),Restrictions.like("username","vipul")));
	        //      c1.addOrder(Order.desc("id"));
	        //      c1.setProjection(Projections.property("username"));
	        //      c1.setProjection(Projections.property("address"));
		int len=s.length;
		System.out.println(len);
		
		ProjectionList p1=Projections.projectionList();         
		for(int i=0; i<len; i++)
		{
	               p1.add(Projections.property(s[i]));
	               System.out.println(s[i]);
	               
	        //        p1.add(Projections.property("address"));
		}           
	                
					c1.setProjection(p1);
	                 List l1 = (List) c1.list();
	               // Iterator i =l1.iterator();
	               // while(i.hasNext())
	                //{
	     //                   Object o[]=(Object [])i.next();
	     //                   System.out.println(o[0] + "==" + o[1]);
	                        
	                        
	            //         String str=(String) i.next();
	          //   System.out.println(str);
	                /*
	                        Object o=i.next();
	                        login l11=(login)o;
	                        System.out.println(l11.getid());
	                        System.out.println(l11.getaddress());
	                        System.out.println(l11.getemail());
	                        System.out.println(l11.getpassword());
	                        System.out.println(l11.getphonenumber());
	                        System.out.println(l11.getusername());
	                */
	                //}
	                System.out.println("save");
	                
	                session.close();
	                sf.close();

			
		
		return l1;
		
	
	}

}